﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bymed.SpineScan.WPF.Model;
using Bymed.SpineScan.Service.Shared;
using Bymed.SpineScan.DataModel;

namespace Bymed.SpineScan.WPF.ViewModel.TestItemViewModel
{
    public class TestItemScoliosisATIViewModel : SingleTestItemViewModel
    {
        /// <summary>
        /// Initializes a new instance of the TestItemScoliosisATIViewModel class.
        /// </summary>
        public TestItemScoliosisATIViewModel(IDataService dataService)
            : base(dataService) { }

        public override bool CheckIfTestFinished()
        {
            if (GraphData.Count == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// Setup the FormattedTestResult property.
        /// </summary>
        public override void SetFormattedTestResult()
        {
            if (FirstTestResult.HasValue || SecondTestResult.HasValue)
            {
                if (FirstTestResult > 0)
                {
                    FormattedTestResult = string.Format("{0}{1}{2}°", TestPositionName, FirstTestResultLabel, FirstTestResult);
                }
                else
                {
                    FormattedTestResult = string.Format("{0}{1}{2}°", TestPositionName, SecondTestResultLabel, SecondTestResult);
                }
            }
        }

        /// <summary>
        /// Initialize all necessary parameters.
        /// Is is invoked by base constructor.
        /// </summary>
        protected override void InitializeParameters()
        {
            TestItemTitle = "躯干倾斜角ATI";
            TestItemName = TestItemDefinition.ScoliosisATITestName;
            FirstTestResultLabel = "左";
            SecondTestResultLabel = "右";
            FirstRangeStartValue = 0;
            SecondRangeStartValue = 0;
            FirstRangeEndValue = 7;
            SecondRangeEndValue = 7;
            FirstMaxValue = 50;
            SecondMaxValue = 50;
            ReverseBackgroundColor = true;

            // Baseline
            for (int i = 0; i < 100; i++)
            {
                GraphBaseLineData.Add(new KeyValuePair<int, double>(i, 0));
            }
        }
    }
}